package cn.shenxd.controller;

import java.util.Random;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.shenxd.entity.User;
import cn.shenxd.service.HelloService;
import cn.shenxd.service.RefactorHelloService;

@RestController
public class ConsumerController  {
	Logger logger = Logger.getLogger(this.getClass());
	
	@Autowired
	HelloService helloService;
	
	@Autowired
	RefactorHelloService refactorHelloService;
	
	@RequestMapping("/feign-consumer")
	public String helloConsumer(){
		return helloService.hello();
	}
	
	@RequestMapping("/feign-consumer2")
	public String helloConsumer2(){
		StringBuilder sb = new StringBuilder();
		sb.append(helloService.hello("shenxd")).append("\n");
		sb.append(helloService.hello("shenxd",28)).append("\n");
		sb.append(helloService.hello(new User("test",12))).append("\n");
		return sb.toString();
	}
	
	@RequestMapping("/feign-consumer3")
	public String helloConsumer3(){
		StringBuilder sb = new StringBuilder();
		sb.append(refactorHelloService.hello("ipq")).append("\n");
		sb.append(refactorHelloService.hello("ipqihujf",28)).append("\n");
		sb.append(refactorHelloService.hello(new cn.shenxd.api.entiy.User("ipqs",12))).append("\n");
		logger.info("refactorHelloService excution res:"+sb.toString());
		return sb.toString();
	}

}
